package com.app.ytong.bean;


import com.alibaba.fastjson.annotation.JSONField;

import java.util.ArrayList;
import java.util.List;

public class UnitListBean extends BaseListBean {



    private ArrayList<UnitListData> list = new ArrayList<UnitListData>();

    public ArrayList<UnitListData> getList() {
        return list;
    }

    public void setList(ArrayList<UnitListData> list) {
        this.list = list;
    }

    @JSONField(serialize = false)
    public void addListBean(UnitListBean listbean) {
        if (listbean == null)
            return;
        if (this.getCurrentPage() == INIT_PAGE) {
            setList(listbean.getList());
        } else {
            if (list == null)
                list = new ArrayList<UnitListData>();
            list.addAll(listbean.getList());
        }
        setListBeanData(listbean);
    }

    public String[] getKnaLists(){
        List<String> knaList = new ArrayList<>();
        for (UnitListData unitListData : list){
            knaList.add(unitListData.getKna());
        }
        String[] knas = new String[knaList.size()];
        return knaList.toArray(knas);
    }

    public String getKidByKey(String key){
        for (UnitListData unitListData : list){
            if(key.equals(unitListData.getKna())){
                return unitListData.getKid();
            }
        }
        return "";
    }

}
